class PrintPrimes {
	public static void main(String[] args) {
		printPrimes(100);
	}

	static void printPrimes(int count) {
		final int ITEMS_PER_LINE = 20;
		final int ITEM_WIDTH=8;

		for(int found=0,curr=2; found<count; curr++) {
			if(isPrime(curr)) {
				found++;
				System.out.printf("%" + ITEM_WIDTH + "d", curr);
				if(found % ITEMS_PER_LINE ==0) {
					System.out.println("");
				}
			}
		}
	}

	static boolean isPrime(int n) {
		for(int i=2; i<=n/2; i++) {
			if(n % i == 0) return false;
		}

		return true;
	}
}
